const Base = require("./base.js");

module.exports = class extends Base {
  /**
   * 列表
   * @param name
   * @returns {Promise<any>}
   */
  async indexAction() {
    const sT = Date.now();
    const cache = this.service("cache/key");
    const result = {};
    result.errno = 0;
    result.data = await cache.get();
    result.time = Date.now() - sT;
    return this.json(this.format(result));
  }

  async delAction() {
    const sT = Date.now();
    const post = this.post();
    const cache = this.service("cache/key");
    const result = {};
    result.errno = 0;
    await this.cache(post.key, null);
    await cache.del(post.key);
    result.time = Date.now() - sT;
    return this.json(this.format(result));
  }
};
